using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics.CodeAnalysis;
using System.Linq;

namespace SellAvi.Model
{
    [Table("TCategories")]
    public partial class TCategory
    {
        [SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
        public TCategory()
        {
            AvitoProducts = new HashSet<AvitoProduct>();
        }

        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        public int Id { get; set; }

        [Required]
        public int RootCategoryId { get; set; }

        [Required]
        [StringLength(4000)]
        public string CategoryName { get; set; }

        [NotMapped]
        public string ShortCategoryName {
            get { return CategoryName.Split(' ').FirstOrDefault(); }
        }

        [StringLength(4000)]
        public string LatinName { get; set; }

        [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
        public virtual ICollection<AvitoProduct> AvitoProducts { get; set; }
    }
}
